<?php
/**
 * Created by PhpStorm.
 * User: yadongw
 * Date: 15-5-26
 * Time: 下午5:50
 */
use UcxApiSdk\Client;
include 'common.php';

if($_POST){
	$client = new Client();
	$auth = $client->getAuth();
	$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'signin';
	try{
		if($type == 'signup'){
			$data = $auth->signUp($_POST['email'], $_POST['password']);
		}else{
			$data = $auth->signIn($_POST['email'], $_POST['password']);
		}
		setCookie('ucx_access_token', $data['access_token']);
		header("location:index.php");
	}catch (\UcxApiSdk\Exceptions\UcxException $e){
		echo "Error: " . $e->getMessage();
	}

}
?>
SignIn:
<form action="?type=signin" method="post">
	<input name="email" />
	<input name="password" />
	<input type="submit" />
</form>

SignUp:
<form action="?type=signup" method="post">
	<input name="email" />
	<input name="password" />
	<input type="submit" />
</form>